package com.ykun.springboot.util;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

public class HttpRequestUtil {
	
	private HttpRequestUtil(){
		
	}
	                 
	/**
	 * 把request中的参数值去除两边空格转为Map格式
	 * @param request
	 * @return
	 */
	public static Map<String,String> toParamsMap(HttpServletRequest request){
		Map<String,String> paramsMap = new HashMap<String,String>();
		Enumeration<String> enumeration = request.getParameterNames();
		while(enumeration.hasMoreElements()){
			String paramname = enumeration.nextElement();
			paramsMap.put(paramname, request.getParameter(paramname).trim());//去除两边空格
			}
		return paramsMap;
	}
	
}
